package com.example.zhihu.model;

import com.example.zhihu.base.BaseModel;
import com.example.zhihu.base.BaseObserver;
import com.example.zhihu.bean.DailyNewsBean;
import com.example.zhihu.not.ApiService;
import com.example.zhihu.not.HttpUlist;
import com.example.zhihu.not.RxUlist;

import io.reactivex.Flowable;
import io.reactivex.Observable;

public class DailyNewsModel extends BaseModel {
    public void addDailyModel(DailyNewsCallBack callBack){
        ApiService apiServer = new HttpUlist().getApiServer(ApiService.sUrl, ApiService.class);
        Observable<DailyNewsBean> latestNews = apiServer.getLatestNews();
        latestNews.compose(RxUlist.RxObservableTransformer())
                .subscribe(new BaseObserver<DailyNewsBean>(this) {
                    @Override
                    protected void onSuccess(DailyNewsBean dailyNewsBean) {
                        callBack.onSuccess(dailyNewsBean);
                    }

                    @Override
                    protected void onFail(String message) {
                        callBack.onFali(message);
                    }
                });

    }
}
